Skip to content

[#370] Backfill user_address on existing trade_history rows#372

Merged
realproject7 merged 1 commit intomainfrom
task/370-backfill-user-address
Mar 19, 2026
Merged

[#370] Backfill user_address on existing trade_history rows#372
realproject7 merged 1 commit intomainfrom
task/370-backfill-user-address

Conversation

@realproject7
Copy link
Copy Markdown
Owner

Summary

  • Adds POST /api/backfill-user-address endpoint that reads trade_history rows with NULL user_address, fetches tx receipts from chain, decodes Mint/Burn events to extract the user address, and updates the rows
  • Protected by CRON_SECRET auth (same pattern as existing cron endpoints)
  • Groups rows by tx_hash to minimize RPC calls
  • Returns detailed error report for any rows that fail to backfill

Fixes #370

Usage

curl -X POST https://plotlink.xyz/api/backfill-user-address \
  -H "Authorization: Bearer $CRON_SECRET"

Test plan

  • Run migration 00019 on Supabase (if not already applied)
  • Trigger endpoint with valid CRON_SECRET and verify rows are updated
  • Verify reader dashboard Trading History shows trades after backfill
  • Confirm endpoint returns 401 without valid auth

🤖 Generated with Claude Code

POST /api/backfill-user-address fetches trade_history rows with NULL
user_address, reads tx receipts from chain, decodes Mint/Burn events
to extract the user address, and updates the rows. Protected by
CRON_SECRET auth. Groups by tx_hash to minimize RPC calls.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Auth pattern matches existing cron endpoints. tx_hash grouping minimizes RPC calls. Event decoding correctly targets mcv2BondEventAbi (Mint/Burn) which both expose the user field. 500-row batching is sensible for a one-off backfill — just re-run until 0 remaining. Error reporting is thorough.

Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: APPROVE

Summary

The PR matches issue #370 with a focused one-off backfill endpoint that populates trade_history.user_address from on-chain Mint/Burn receipts. The auth model and server-side Supabase usage match the existing cron/backfill routes.

Findings

  • [info] lint-and-typecheck was still pending at review time.
    • File: src/app/api/backfill-user-address/route.ts:1
    • Suggestion: Wait for required checks before merging.

Decision

Approve. The change is scoped correctly to the backfill requirement and follows established patterns in the repo.

@realproject7 realproject7 merged commit eab41e6 into main Mar 19, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Infra] Backfill user_address on existing trade_history rows

2 participants